#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/12/27 9:51
# @Author: 张磊
# @Email: 1273104996@qq.com
# @File：community_page.py
# from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy as By
from pages.base_page import BasePage
from config.config import config

# config = {
#     "platformName": "Android",
#     "deviceName": "127.0.0.0:62001",
#     "platformVersion": "7.1.2",
#     "appPackage": "com.gfeng.daydaycook",
#     "appActivity": ".activity.TabActivity",
#     "noReset": True
# }
class Community(BasePage):
    community_locator = (By.XPATH, "//android.widget.TabWidget[@resource-id=\"android:id/tabs\"]/android.widget.RelativeLayout[2]/android.widget.RelativeLayout[1]/android.widget.ImageView[1]")               # 社区定位器
    attention_locator = (By.XPATH, "//android.widget.TextView[@text=\"关注\"]")    # 关注定位器
    recommend_locator = (By.XPATH, "//android.widget.TextView[@text=\"推荐\"]")    # 推荐定位器
    newest_locator = (By.XPATH, "//android.widget.TextView[@text=\"最新\"]")       # 最新定位器
    search_locator = (By.ID, "com.gfeng.daydaycook:id/searchIv")                  # 社区内搜索框定位器

    def click_community(self):
        self.driver.find_element(*self.community_locator).click()  # 点击社区

    def click_attention(self):
        self.driver.find_element(*self.attention_locator).click()  # 点击关注

    def click_recommend(self):
        self.driver.find_element(*self.recommend_locator).click()  # 点击推荐

    def click_newest(self):
        self.driver.find_element(*self.newest_locator).click()     # 点击最新

    def click_search(self):
        self.driver.find_element(*self.search_locator).click()     # 点击搜索框